/*global class CheckUnfinichAssingTaskScheduler implements Schedulable {
    global void execute(SchedulableContext sc) {
    	*/
global class CheckUnfinichAssingTaskScheduler  {
    global static void execute() {
        Integer year = System.now().year();
    	Integer quarter = Integer.valueOf((System.now().month()-1) / 3 +1 );
    	//判断任务是否完成
    	String only = 'GetUnfinishAssignTaskShceduler'+year + quarter;
    	List<SchedulerExcuetLog__c> seList =  [select Id , Only__c,Message__c , IsFinished__c , Stage1__c,Stage2__c,Stage3__c,Stage4__c from SchedulerExcuetLog__c  where Only__c =:only ];
    	
    	///任务完成了
    	if(seList.size() >0 && seList[0].IsFinished__c == true) return;
    	SchedulerExcuetLog__c se = seList.size() >0 ? seList[0] : new SchedulerExcuetLog__c(Only__c = only);

    	if(se.Stage2__c != null && se.Stage2__c == true && se.Message__c == null ){
    		se.Stage3__c = true;
    		se.IsFinished__c = true;
    		upsert se;
    	}

    }
}